<template>
  <div>
    <van-cell v-for="(item,$index) in data" :key="$index" @click="goToDetail(item)">
      <template #title>
        <van-row>车主姓名：{{item.ownerName}}</van-row>
        <van-row>
          状态：
          <van-tag round :type="statusColor[item.dataStatus]">{{item.dataStatus | statusFilter}}</van-tag>
        </van-row>
      </template>
      <template #label>
        <van-row>车牌号码：{{item.carPlate}}</van-row>
        <van-row>租赁期限：{{item.czqxQ | filterDate}} 至 {{item.czqxZ | filterDate}}</van-row>
      </template>

    </van-cell>
  </div>
</template>

<script>
import Vue from "vue";
import { Cell, Tag } from "vant";
Vue.use(Cell);
Vue.use(Tag);
// 表单配置
import { enterpriseCarForm } from "../../components/form/config";
export default {
  name: "infoDetail",
  props: {
    data: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      statusColor: {
        0: "warning",
        1: "primary",
        2: "success",
        3: "danger"
      }
    };
  },
  filters: {
    filterDate(val) {
      let d = new Date(val);
      return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDay();
    },
    statusFilter: function(val) {
      switch (val) {
        case 0:
          return "暂存";
        case 1:
          return "待审核";
        case 2:
          return "已审核";
        case 3:
          return "不合格";
      }
    }
  },
  methods: {
    goToDetail(val) {
      this.$router.push({
        name: "enterpriseCarDetail",

        params: {
          form: enterpriseCarForm(val),
          isModify: true,
          name:"enterpriseCar",
          data:val,
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
</style>
